package topcoder;

public class BinaryCode {

	int max,len;
	String input;
	String[] result={"NONE","NONE"};
	
	public String[] decode(String str)
	{
		len=str.length();
		max=0;
		input=str;
		solve("");
		return result;
	}
	
	
	private void solve(String sub)
	{
		if(max==2)return;
		if(sub.length()==len)
		{
			int n=input.charAt(len-1)-'0';
			int cur=sub.charAt(sub.length()-1)-'0';
			int cur1=0;
			if(sub.length()>1)cur1=sub.charAt(sub.length()-2)-'0';
			if(n==cur+cur1){
				if(sub.charAt(0)=='0')result[0]=sub;
				else result[1]=sub;
				max++;
			}
			return;
		}
		
		if(isOk(sub,'0'))
		{
			solve(sub+"0");
		}
		
		if(isOk(sub,'1'))
		{
			solve(sub+"1");
		}
	}
	
	
	private boolean isOk(String sub,char ch)
	{
		int n=input.charAt(sub.length())-'0';
		if(sub.length()==0)
		{
			if(n==1||(n==0&&ch=='0')||(n==2&&ch=='1'))return true;
		}else{
			int n1=input.charAt(sub.length()-1)-'0';
			int cur=sub.charAt(sub.length()-1)-'0';
			int cur1=0;
			if(sub.length()>1)cur1=sub.charAt(sub.length()-2)-'0';
			if((n1==cur+ch-'0'+cur1)&&(n>=cur+ch-'0'))return true;
		}
		return false;
	}
	
	
	public static void main(String[] args) {
		String[] s=new BinaryCode().decode("123210122");
		System.out.println(s[0]+","+s[1]);
	}
}
